package LeetCode.LeetCodeHot;

/**
 * 盛水最多的容器
 * @author lumin
 * @date 2022/03/28 16:55
 **/
public class Num11 {
    public static int maxArea(int[] height) {
        int left = 0;
        int right = height.length - 1;
        int maxHeight = 0;
        while(left < right){
            int sum = Math.abs(right - left) * (Math.min(height[left],height[right]));
            maxHeight = Math.max(maxHeight,sum);
            if(height[left] <= height[right]){
                left++;
            }else{
                right--;
            }
        }
        return maxHeight;
    }

    public static void main(String[] args) {
        int[] arr = {1,8,6,2,5,4,8,3,7};
        System.out.println(maxArea(arr));
    }
}